#pragma once

#include <MyFC/Widget.h>
#include <MyFC/Container.h>
#include "Types.h"
#include "DLL.h"

namespace My {

class Timeline;

/**
 * TimeRuler widget displays a ruler with frame 
 * numbers for a Sequence inside a Timeline.
 */
class DLL_API TimeRuler : public Widget, public Container
{
	class Thumb : public My::Control
	{
	private:
		TimeRuler &		m_TimeRuler;
		Timeline &		m_Timeline;
		int				m_StartPos;
		int				m_StartValue;
	public:
		Thumb(TimeRuler &); 
	public:
		virtual bool Visible() const;
		virtual CRect Bounds() const;
		virtual bool HandleDragStart(unsigned int flags, const CPoint & p0, const CPoint & p);
		virtual void HandleDragEnd(unsigned int flags, const CPoint & p);
		virtual void HandleDragging(unsigned int flags, const CPoint & p);
	};
private:
	CString GetLabel(int frame);
public:
	TimeRuler(Timeline &);
public:
	void UpdateScale();
public:
	virtual CSize GetPreferredSize() const;
	virtual String Hint() const; 
	virtual void ProcessEvent(Event &);
	virtual void HandleLeftDown(unsigned int flags, const CPoint & p);
	virtual void HandleLeftUp(unsigned int flags, const CPoint & p);
	virtual void HandlePaint(CDC * pDC, const CRect & r);
private:
	Timeline &		m_Timeline;
	Thumb			m_Thumb;
	int				m_Span;
	int				m_ThumbSize;
};

} // My
